/**
 * @author of2198
 * @date 2017/5/5.
 * @description
 */
declare const $CONST_PROJECT: any;
declare let window: any;

export const systemIdMap = {
  "0032": "d2c",
  "0031": "d2p", //写错了，先兼容一下之后删了
  "0033": "d2p"
};

export const sceneMap = {
  onlineMall: "d2c",
  communityStore: "d2c",
  onlineDistribution: "d2p"
};

export const systemCodeZipMap = {
  d2c: "H4sIAAAAAAAAA0sxSg4uyS9KBQDJOKt4CAAAAA==",
  d2p: "H4sIAAAAAAAAA0sxKgAAo5/qDQMAAAA=",
  ehome: "H4sIAAAAAAAAA0vNyM9NBQDs3GLHBQAAAA=="
};

export const getSystemCodeZip = () => {
  let systemCode = getSystemCode();
  return systemCodeZipMap[systemCode];
};

export const getSystemCode = () => {
  let systemCode = "";
  if (window.getReactContext) {
    let context = window.getReactContext();
    if (context && context.user) {
      systemCode = sceneMap[context.user.sceneName];
    }
  }
  //兼容老的取systemId方式
  if (!systemCode) {
    let project = $CONST_PROJECT;
    if (project && typeof project == "string") {
      project = JSON.parse(project);
    }
    let systemId = project.SystemId;
    systemCode = systemIdMap[systemId];
  }
  return systemCode || "d2c";
};
